<?php
class ActlotteryModel extends Model {
	
	/**
	 * 根据id，获取抽奖活动详情
	 * @param  int $id
	 * @return 数组    $json
	 */
	public function getLotteryDetail(){
		
		$id = I("id",0,'intval');
		
		$map['id'] = $id;
		$json = sendRest("Actlottery/view",$map);
		
		return $json;
		
	}
	
	/**
	 * 检查用户是否中奖
	 * @param $id     活动id 
	 * @param $userid 用户编号 
	 */
	public function checkUserWinning(){
		
		$user = getMember();
			
		$id     = I('id',0,'intval');
		$userid = $user['id'];
		
		$map['id']     = $id;
		$map['userid'] = $userid;
		$json = sendRest("Actlottery/check",$map);
		
		//返回奖品图片列表
		$data = sendRest("Actlottery/view",$map);
		$arr  = array();
		foreach($data['data']['list'] as $k=>$v){
			$arr[$k]['id']      = $v['id'];
			$arr[$k]['fileurl'] = find_resource($v['solevar']);
		}
		$json['json'] = $arr;
		
		if(empty($userid)&&$json['status']==1&&$json['data']['status']==1){
			$json['auto'] = 1; //未登陆/注册标识
		}

		$_SESSION[C('REFER_URL')] = I("server.REQUEST_URI"); //记录当前页面
		session(C('USER_AUTH_PRIZE'),$json);
		
		return $json;
		
	}
	
	/**
	 * 获取场景抽奖活动
	 */
	public function getActlottery($sence){
		
		$map['sence'] = $sence;
		
		$json = sendRest("Actlottery/select",$map);
		return $json;
	}
	
}

?>